home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / kcl / akcl / akcl1615.lha / doc / print_doc.c < prev    next >
C/C++ Source or Header  |  1988-09-30  |  705b  |  32 lines

  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <sys/file.h>
  4.  
  5. #define error(a,b) do {printf(a,b); exit(1);}while(0)
  6.  
  7. main(argc,argv)
  8. int argc; char* argv[];
  9. {FILE *fd;
  10.  char *name=argv[1];
  11.  int filepos;
  12. char ch;
  13.  if (argc != 3) error("Need 2 args %d provided",argc-1);
  14.  sscanf(argv[2],"%d",&filepos);
  15.     fd = fopen (name, "r");
  16.   if (!fd)
  17.    error  ("Cannot open doc string file \"%s\"", name);
  18.   if (fseek (fd, filepos, 0))
  19.     {      close (fd);
  20.        printf("Going to pos %d.  ",filepos);
  21.        error ("Position out of range in doc string file \"%s\"",
  22.           name);}
  23.  while(ch=fgetc(fd))
  24.    { if (ch==EOF || ch=='\037') break;
  25.      fputc(ch,stdout);}
  26.  fputc('\n',stdout);
  27.  fclose(fd);
  28. }
  29.  
  30.        
  31.        
  32.